package cn.zs.groupmarket.domain.activity.service.trial.thread;

import cn.zs.groupmarket.domain.activity.adapter.repository.IActivityRepository;
import cn.zs.groupmarket.domain.activity.model.valobj.GroupBuyActivityDiscountVO;
import cn.zs.groupmarket.domain.activity.model.valobj.SCSkuActivityVO;

import java.util.concurrent.Callable;

/**
 * @Description:
 * @Auther: zs
 * @Date: 2024/12/23/16:45
 */
public class QueryGroupBuyActivityDiscountVOThreadTask implements Callable<GroupBuyActivityDiscountVO> {

    /**
     * 来源
     * */
    private final String source;

    /**
     * 渠道
     * */
    private final String channel;

    /**
     * 商品id
     * */
    private final String goodsId;


    private final IActivityRepository activityRepository;

    public QueryGroupBuyActivityDiscountVOThreadTask(String source, String channel, String goodsId,IActivityRepository activityRepository) {
        this.source = source;
        this.channel = channel;
        this.goodsId = goodsId;
        this.activityRepository = activityRepository;
    }

    @Override
    public GroupBuyActivityDiscountVO call() throws Exception {
        // 查询渠道商品活动配置关联配置
        SCSkuActivityVO scSkuActivityVO = activityRepository.querySCSkuActivityByGoodsId(source, channel, goodsId);
        if (null == scSkuActivityVO) return null;
        return activityRepository.queryGroupBuyActivityDiscountVO(scSkuActivityVO.getActivityId());
    }
}
